﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using System.Xml;

namespace GameBanChim_Version1
{
    public class Player : VisibleGameEntity
    {
        private int _mark;

        public int Mark
        {
            get { return _mark; }
            set { _mark = value; }
        }

        private int _level = 1;

        public int Level
        {
            get { return _level; }
            set { _level = value; }
        }

        private int _markStore;

        public int MarkStore
        {
            get { return _markStore; }
            set { _markStore = value; }
        }

        private MessageStr _playerMessage;

        public MessageStr PlayerMessage
        {
            get { return _playerMessage; }
            set { _playerMessage = value; }
        }

        private int _normalBirdCount = 0;

        public int NormalBirdCount
        {
            get { return _normalBirdCount; }
            set { _normalBirdCount = value; }
        }

        private int _largeBirdCount = 0;

        public int LargeBirdCount
        {
            get { return _largeBirdCount; }
            set { _largeBirdCount = value; }
        }

        SpecialSkill _skillSpecial;

        public SpecialSkill SkillSpecial
        {
            get { return _skillSpecial; }
            set { _skillSpecial = value; }
        }

        bool _useSkillSpecial = false;

        public bool UseSkillSpecial
        {
            get { return _useSkillSpecial; }
            set { _useSkillSpecial = value; }
        }

        SlowSkill _skillSlow;

        public SlowSkill SkillSlow
        {
            get { return _skillSlow; }
            set { _skillSlow = value; }
        }

        bool _useSkillSlow = false;

        public bool UseSkillSlow
        {
            get { return _useSkillSlow; }
            set { _useSkillSlow = value; }
        }

        SleepSkill _skillSleep;

        public SleepSkill SkillSleep
        {
            get { return _skillSleep; }
            set { _skillSleep = value; }
        }

        bool _useSkillSleep = false;

        public bool UseSkillSleep
        {
            get { return _useSkillSleep; }
            set { _useSkillSleep = value; }
        }

        public void ResetMark()
        {
            //_markStore += _mark;
            _largeBirdCount = 0;
            _normalBirdCount = 0;
            _mark = 0;
        }

        public void ResetAllMark()
        {
            _mark = 0;
            _largeBirdCount = 0;
            _normalBirdCount = 0;
            _markStore = 0;
            ResetSkill();
        }

        public void ResetSkill()
        {
            _useSkillSpecial = false;
            _skillSpecial.Reset();
            _useSkillSlow = false;
            _skillSlow.Reset();
            _useSkillSleep = false;
            _skillSleep.Reset();
        }

        public int getLevelCurrentGame(int iCurrenLevelGame)
        {
            _level = iCurrenLevelGame;
            return _level;
        }

        public Player(ContentManager Content)
        {
            _playerMessage = new MessageStr(Content, 2, Color.Yellow, "");
            _playerMessage.X = 10;
            _playerMessage.Y = 560;

            _skillSpecial = new SpecialSkill();
            _skillSpecial.MyInit(Content);

            _skillSlow = new SlowSkill();
            _skillSlow.MyInit(Content);

            _skillSleep = new SleepSkill();
            _skillSleep.MyInit(Content);

        }
 
        public override bool Init(ContentManager Content, int index, string strResourceXML)
        {
            return base.Init(Content, index, strResourceXML);
        }

        public override VisibleGameObject Clone()
        {
            return base.Clone();
        }

        public override void Update(GameTime gameTime)
        {
            _playerMessage.MessageStr1 = "Your gold: " + _mark.ToString();
            _skillSpecial.Update(gameTime);
            if (_level == 2 || _level == 3)
            {
                _skillSlow.Update(gameTime);
            }
            if (_level == 3)
            {
                _skillSleep.Update(gameTime);
            }
        }

        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            _playerMessage.Draw(gameTime, spriteBatch);
            _skillSpecial.Draw(gameTime, spriteBatch);
            if (_level == 2 || _level == 3)
            {
                _skillSlow.Draw(gameTime, spriteBatch);
            }
            if (_level == 3)
            {
                _skillSleep.Draw(gameTime, spriteBatch);
            }
        }
    }
}
